package com.aidex.biz.controller;

import java.util.List;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.poi.ExcelUtil;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import com.aidex.common.core.controller.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.aidex.biz.domain.BizAssessDetailsInfo;
import com.aidex.biz.service.BizAssessDetailsInfoService;
import com.aidex.common.utils.SecurityUtils;

/**
 * 考核详情Controller
 * @author sean
 * @email 2074844820@qq.com
 * @date 2024-11-29
 */
@RestController
@RequestMapping("/biz/bizAssessDetailsInfo")
public class BizAssessDetailsInfoController extends BaseController
{
    @Autowired
    private BizAssessDetailsInfoService bizAssessDetailsInfoService;

    /**
     * 查询考核详情列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessDetailsInfo:list')")
    @GetMapping("/list")
    public R<PageInfo> list(BizAssessDetailsInfo bizAssessDetailsInfo, HttpServletRequest request, HttpServletResponse response)
    {

        bizAssessDetailsInfo.setPage(new PageDomain(request, response));
        return R.data(bizAssessDetailsInfoService.findPage(bizAssessDetailsInfo));
    }

    /**
     * 获取考核详情详细信息
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessDetailsInfo:query')")
    @GetMapping(value = "/{id}")
    public R<BizAssessDetailsInfo> detail(@PathVariable("id") String id)
    {
        return R.data(bizAssessDetailsInfoService.get(id));
    }

    /**
     * 新增考核详情
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessDetailsInfo:add')")
    @Log(title = "考核详情", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  BizAssessDetailsInfo bizAssessDetailsInfo)
    {
        return R.status(bizAssessDetailsInfoService.save(bizAssessDetailsInfo));
    }

    /**
     * 修改考核详情
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessDetailsInfo:edit')")
    @Log(title = "考核详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated BizAssessDetailsInfo bizAssessDetailsInfo)
    {
        return R.status(bizAssessDetailsInfoService.save(bizAssessDetailsInfo));
    }


    /**
     * 删除考核详情
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessDetailsInfo:remove')")
    @Log(title = "考核详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids)
    {
        return R.status(bizAssessDetailsInfoService.deleteBizAssessDetailsInfoByIds(ids));
    }

    /**
     * 获取最大编号
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessDetailsInfo:query')")
    @GetMapping("/findMaxSort")
    public R findMaxSort()
    {
        return R.data(bizAssessDetailsInfoService.findMaxSort(new BizAssessDetailsInfo()));
    }

    /**
     * 导出考核详情列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizAssessDetailsInfo:export')")
    @Log(title = "考核详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(BizAssessDetailsInfo bizAssessDetailsInfo)
    {

            if(SecurityUtils.isAdmin(SecurityUtils.getUserId())){
                    bizAssessDetailsInfo.setCompanyId(null);
            }else{
                         bizAssessDetailsInfo.setCompanyId(SecurityUtils.getLoginUser().getUser().getCompanyId());
                     }
        List<BizAssessDetailsInfo> list = bizAssessDetailsInfoService.findList(bizAssessDetailsInfo);
        ExcelUtil<BizAssessDetailsInfo> util = new ExcelUtil<BizAssessDetailsInfo>(BizAssessDetailsInfo.class);
        return util.exportExcel(list, "考核详情数据");
    }

}
